package com.liuqi.knet;

/**
 * @author liuqi
 * @date 2024/12/17 15:29
 **/
public class Constants {

    /**
     * 服务端 boss group name
     */
    public static String serverBossGroupName = "KNet-Accept";

    /**
     * 服务端 worker group name
     */
    public static String serverWorkerGroupName = "KNet-Server-Work";

    /**
     * 客户端 worker group name
     */
    public static String clientWorkerGroupName = "KNet-Client-Work";

    /**
     * 检查请求超时请求的线程名称
     */
    public static String responseFutureTimeoutScanThreadName = "KNet-Response-Timeout-Scan-Timer-Thread";

    /**
     * 客户端或服务端 worker thread 线程数
     */
    public static int workerThreads;
    static {
        try {
            workerThreads = Runtime.getRuntime().availableProcessors() * 2;
        } catch (Throwable e) {
            workerThreads = 10;
        }
    }

    // =========== 验证类型

    /**
     * 保存上一次心跳的时间戳 的key
     */
    public static final String HEARTBEAT_ATTR_KEY = "heartbeat";

    public static void setServerBossGroupName(String serverBossGroupName) {
        Constants.serverBossGroupName = serverBossGroupName;
    }

    public static void setServerWorkerGroupName(String serverWorkerGroupName) {
        Constants.serverWorkerGroupName = serverWorkerGroupName;
    }

    public static void setClientWorkerGroupName(String clientWorkerGroupName) {
        Constants.clientWorkerGroupName = clientWorkerGroupName;
    }

    public static void setResponseFutureTimeoutScanThreadName(String responseFutureTimeoutScanThreadName) {
        Constants.responseFutureTimeoutScanThreadName = responseFutureTimeoutScanThreadName;
    }

    public static void setWorkerThreads(int workerThreads) {
        Constants.workerThreads = workerThreads;
    }
}
